class Solution
{
public:
    string formatString(string str, vector<char>& arg)
    {
        string ans;
        reverse(arg.begin(), arg.end());
        for (int i = 0; i < str.size(); i++)
        {
            if (str[i] == '%' && str[i + 1] == 's')
            {
                ans += arg.back();
                arg.pop_back();
                i++;
            }
            else ans += str[i];
        }
        while (!arg.empty())
        {
            ans += arg.back();
            arg.pop_back();
        }
        return ans;
    }
};